package com.jueling.culture.config;



import com.jueling.culture.core.interceptor.LoginHandlerInterceptorAdapter;
import com.jueling.culture.core.interceptor.PermissionHandlerInterceptorAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author linp
 * @date  2019/7/27
 */
@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    /**
     * 认证拦截器
     */
    @Autowired
    private LoginHandlerInterceptorAdapter loginHandlerInterceptorAdapter;

    @Autowired
    private PermissionHandlerInterceptorAdapter permissionHandlerInterceptorAdapter;

    /**
     * 拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginHandlerInterceptorAdapter)
                .addPathPatterns("/api/**");
        registry.addInterceptor(permissionHandlerInterceptorAdapter)
                .addPathPatterns("/**");
    }

}
